// mine/pages/recipesinfo/index.js
const $api = require("../../../api/mine").API

Page({

  /**
   * 页面的初始数据
   */
  data: {
    imgurl:"https://img01.yzcdn.cn/vant/apple-1.jpg",
    dict_key:1,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var t = this
    t.getWeekType()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    var t= this
    t.getChildDiet()
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },
  // 获取星期

  getWeekType(){
    var t= this
    $api.getWeekType().then(res=>{
      t.setData({
        typelists:res.data,
        dict_key:res.data[0].dict_key
      })
    })
  },
  // 选择星期
  chooseweek(e){
    var t = this
    t.setData({
      dict_key:e.currentTarget.dataset.dict_key
    })
    t.getChildDiet()
  },
  // 我的-食谱列表
  getChildDiet(){
    var t = this,
    data = {
      child_id:wx.getStorageSync('child_one').child_id,
      week:t.data.dict_key,
      institution_id:wx.getStorageSync('classinfo').institution_id,
      class_id:wx.getStorageSync('classinfo').class_id,
    }
    $api.getChildDiet(data).then(res=>{
      t.setData({
        info:res.data
      })
    })
  }
})